var sliderWidth = 57.6; // 需要设置slider的宽度，用于计算中间位置
var app = getApp()
Page({
  data: {
    tabs: ["全部", "借阅中", "已归还"],
    activeIndex: 0,
    statuses: ''
  },

  tabClick: function (e) {
    this.setData({
      activeIndex: e.currentTarget.id,
      sliderOffset: e.currentTarget.offsetLeft,
      statuses: this.getStatus(e.currentTarget.id)
    });
  },

  getStatus: function (activeIndex) {
    if (activeIndex == 0) {
      return '';
    } else if (activeIndex == 1) {
      return '1';
    } else if (activeIndex == 2) {
      return '2';
    } else if (activeIndex == 3) {
      return '3';
    } else if (activeIndex == 4) {
      return '4';
    }
  },


  onLoad: function (options) {
    // 生命周期函数--监听页面加载
    var that = this;

    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
          sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
        });
      }
    });
  },

  onReady: function () {
    // 生命周期函数--监听页面初次渲染完成

  },

  onShow: function () {
  },
  onHide: function () {
    // 生命周期函数--监听页面隐藏

  },
  onUnload: function () {
    // 生命周期函数--监听页面卸载

  },
  onPullDownRefresh: function () {
    // 页面相关事件处理函数--监听用户下拉动作

  },
  onReachBottom: function () {
    // 页面上拉触底事件的处理函数

  }

})